import java.util.Scanner;

public class Login {
    public String userName = "zhangsan";
    public String passWord = "123456";
//    public void match(String userName,String passWord) {
//        if(!this.userName.equals(userName)) {
//            System.out.println("用户名不匹配...");
//            return;
//        }
//        if(!this.passWord.equals(passWord)) {
//            System.out.println("密码错误...");
//            return;
//        }
//        System.out.println("登陆成功!");
//    }

    public void match(String userName,String passWord) throws UserNameException,PassWordException{
        if(!this.userName.equals(userName)) {
            //System.out.println("用户名不匹配...");
            //return;
            throw new UserNameException("用户名不匹配异常");
        }
        if(!this.passWord.equals(passWord)) {
            //System.out.println("密码错误...");
            //return;
            throw new RuntimeException("密码错误异常");
        }
        System.out.println("登陆成功!");
    }
    public static void main(String[] args) {
        Login login = new Login();
        try {
            login.match("zhangsan","1234567");
        } catch (UserNameException e) {
            e.printStackTrace();
            System.out.println("用户名不匹配异常...");
        } catch (PassWordException e) {
            System.out.println("密码错误异常...");
            e.printStackTrace();
        }
    }
}
